package com.example.administrator.reader.utils;


import com.example.administrator.reader.fragment.BaseFragment;
import com.example.administrator.reader.fragment.CityFragment;
import com.example.administrator.reader.fragment.UserFragment;
import com.example.administrator.reader.fragment.ShelfFragment;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016-09-04.
 */
public class FragmentUtils {
    public static Map<Integer, BaseFragment> fragments = new HashMap<>();

    public static BaseFragment getFragment(int position) {
        BaseFragment baseFragment = fragments.get(position);
        if (baseFragment == null) {
            if (position == 0) {
                baseFragment = new ShelfFragment();
            } else if (position == 1) {
                baseFragment = new CityFragment();
            } else if (position == 2) {
                baseFragment = new UserFragment();
            }
            fragments.put(position, baseFragment);
        }
        return baseFragment;
    }
}
